<?php
	include_once 'isLogin.php';

	$table_name = "companies";
	$table_detail = "companies_detail";
	$table_categories="companies_categories";
	$key_index = array('title','content','upid','state');
	
	$colors = array(
				'state'=>array('0'=>'#ff0000','1'=>'#16d316'),
			);
	$names = array(
				'state'=>array('0'=>'禁用','1'=>'可用'),
			);
	$sql=$table_name." c left join ".$table_categories." g on c.upid=g.sort where g.upid=".$_GET['id'];
	$row=$commonc->getList($sql, $sqlnum='', $key="c.title,c.star,c.id",$debug='0');
    //var_dump($_GET['id']);
	//修改
	if($_GET['action']=='edit'){
		$arr = array($key_index[$_POST['index']]=>$_POST['value']);
		echo $commonc->update($table_name,$arr,"id='".$_POST['value_id']."'");
		exit();
	}
	//搜索
	if($_GET['submit']=='搜索'){
		$where ='';
		if($_GET['company_name']!=''&&$_GET['company_name']!=null)
		{
			$where = " where c.title like '%".$_GET['company_name']."%'";
		}
		
		if($_GET['company_trade']!=''&&$_GET['company_trade']!=null)
		{
			if($where =='')
			{
				$where = " where c.trade_id = '".$_GET['company_trade']."'";
			}
			else
			{
				$where .= " and c.trade_id = '".$_GET['company_trade']."'";
			}
			
		}
		if($_GET['company_level']!=''&&$_GET['company_level']!=null)
		{
			if($where =='')
			{
				$where = " where c.level_id = '".$_GET['company_level']."'";
			}
			else
			{
				$where .= " and c.level_id = '".$_GET['company_level']."'";
			}
			
		}
	}
	$smarty->assign("row",$row['result']);
	$smarty->assign('page',$row['page']);
	$smarty->display($_filename.".html");
?>